Attribute VB_Name = "regexp"
Function rex(ByVal Range1 As Range, Pattern As String, index As Integer) As String
Dim regex As Object
Set regex = mRex(Pattern)
    
Set mc = regex.Execute(Range1.Value)
rex = mc(index).Value
End Function

Function rexReplace(Pattern As String, Found As String, Replace As String)
Dim regex As Object
Set regex = mRex(Pattern)
rexReplace = regex.Replace(Found, Replace)
End Function

Private Function mRex(Pattern As String) As Object
Dim regex As Object
Set regex = CreateObject("VBScript.RegExp")
    With regex
        .Global = True
        .IgnoreCase = True
        .Pattern = Pattern
    End With
Set mRex = regex
End Function

